﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
using res = Sob.Resource.Models.Article.Article;
using resWeb = Sob.Resource.Models.Web.Web;

namespace Eieboom.Models
{
    /// <summary>
    /// 文章实体类
    /// </summary>
    public class ArticleModel
    {
        public int ID { get; set; }

        [Required(ErrorMessageResourceType = typeof(resWeb), ErrorMessageResourceName = "Common_Required_Msg")]
        [StringLength(100, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "Title_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "Title")]
        public string Title { get; set; }

        [StringLength(400, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "Summary_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "Summary")]
        public string Summary { get; set; }

        [Required(ErrorMessageResourceType = typeof(resWeb), ErrorMessageResourceName = "Common_Required_Msg")]
        [Display(ResourceType = typeof(res), Name = "Content")]
        public string Content { get; set; }

        [Required(ErrorMessageResourceType = typeof(resWeb), ErrorMessageResourceName = "Common_Required_Msg")]
        [Display(ResourceType = typeof(res), Name = "CateId")]
        public int CateId { get; set; }

        [StringLength(50, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "Tags_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "Tags")]
        public string Tags { get; set; }

        // 是否允许评论 1：是；2：否
        [Display(ResourceType = typeof(res), Name = "ReplyPermit")]
        public byte ReplyPermit { get; set; }

        // 状态 1：立即发布；2：保存草稿
        [Display(ResourceType = typeof(res), Name = "Status")]
        public byte Status { get; set; }

        [Display(ResourceType = typeof(res), Name = "IsCommend")]
        public byte IsCommend { get; set; }

        [Display(ResourceType = typeof(res), Name = "IsTop")]
        public byte IsTop { get; set; }

        [StringLength(500, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "SeoTitle_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "SeoTitle")]
        public string SeoTitle { get; set; }

        [StringLength(1000, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "SeoDescription_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "SeoDescription")]
        public string SeoDescription { get; set; }

        [StringLength(500, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "Seokeywords_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "Seokeywords")]
        public string Seokeywords { get; set; }

        [StringLength(1000, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "SeoMetas_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "SeoMetas")]
        public string SeoMetas { get; set; }

        [StringLength(60, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "ReName_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "ReName")]
        [RegularExpression(@"^[a-zA-Z0-9\-]+$", ErrorMessageResourceType = typeof(resWeb), ErrorMessageResourceName = "Common_Reg_Msg")]
        public string ReName { get; set; }
    }

    public class PostModel
    {
        public int ID { get; set; }

        [Required(ErrorMessageResourceType = typeof(resWeb), ErrorMessageResourceName = "Common_Required_Msg")]
        [StringLength(20, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "UserName_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "UserName")]
        public string UserName { get; set; }

        [Required(ErrorMessageResourceType = typeof(resWeb), ErrorMessageResourceName = "Common_Required_Msg")]
        [StringLength(100, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "Title_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "Title")]
        public string Title { get; set; }

        [Required(ErrorMessageResourceType = typeof(resWeb), ErrorMessageResourceName = "Common_Required_Msg")]
        [Display(ResourceType = typeof(res), Name = "Content")]
        public string Content { get; set; }

        [Required(ErrorMessageResourceType = typeof(resWeb), ErrorMessageResourceName = "Common_Required_Msg")]
        [Display(ResourceType = typeof(res), Name = "CateId")]
        public int CateId { get; set; }
    }

    public class ReplyModel
    {
        public int ReplyId { get; set; }

        public int ArticleId { get; set; }

        public int CateId { get; set; }

        [Display(ResourceType = typeof(res), Name = "ReplyPermit")]
        public byte ReplyPermit { get; set; }

        [Required(ErrorMessageResourceType = typeof(resWeb), ErrorMessageResourceName = "Common_Required_Msg")]
        [StringLength(20, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "UserName_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "UserName")]
        public string UserName { get; set; }

        [StringLength(30, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "Email_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "Email")]
        public string Email { get; set; }

        [StringLength(100, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "Url_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "Url")]
        public string Url { get; set; }

        [Required(ErrorMessageResourceType = typeof(resWeb), ErrorMessageResourceName = "Common_Required_Msg")]
        [Display(ResourceType = typeof(res), Name = "Content")]
        //[Required(ErrorMessageResourceType = typeof(Sob.Resource.Entity.ReplyModel), ErrorMessageResourceName = "Common_Required_ErrorMessage")]
        //[Display(ResourceType = typeof(Sob.Resource.Entity.ReplyModel), Name = "CONTENT_DisplayName")]
        public string Reply { get; set; }
    }

    public class PostReplyModel
    {
        public int Id { get; set; }

        public int PostId { get; set; }

        public int CateId { get; set; }

        [Required(ErrorMessageResourceType = typeof(resWeb), ErrorMessageResourceName = "Common_Required_Msg")]
        [StringLength(20, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "UserName_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "UserName")]
        public string UserName { get; set; }

        [Required(ErrorMessageResourceType = typeof(resWeb), ErrorMessageResourceName = "Common_Required_Msg")]
        [Display(ResourceType = typeof(res), Name = "Message")]
        public string Message { get; set; }
    }


    public class NoteModel
    {
        public int NoteId { get; set; }

        public int CateId { get; set; }

        [Required(ErrorMessageResourceType = typeof(resWeb), ErrorMessageResourceName = "Common_Required_Msg")]
        [StringLength(20, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "UserName_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "UserName")]
        public string UserName { get; set; }

        [StringLength(30, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "Email_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "Email")]
        public string Email { get; set; }

        [StringLength(100, ErrorMessageResourceType = typeof(res), ErrorMessageResourceName = "Url_Length_Msg")]
        [Display(ResourceType = typeof(res), Name = "Url")]
        public string Url { get; set; }

        [Required(ErrorMessageResourceType = typeof(resWeb), ErrorMessageResourceName = "Common_Required_Msg")]
        [Display(ResourceType = typeof(res), Name = "Content")]
        public string Reply { get; set; }
    }

    //文章按月归档
    public class ArticleArchives
    {
        public int Year { get; set; }
        public int Month { get; set; }
        public int Count { get; set; }
    }

    /// <summary>
    /// 文章带插图
    /// </summary>
    public class ArtilceWithDecorate : blog_varticle
    {
        public string Decorate { get; set; }
        public string FullSummary { get; set; }
    }

}